//
//  BCWalletExchangeDataModel.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2019/1/21.
//  Copyright © 2019 guoshikeji. All rights reserved.
//

#import "BCWalletExchangeDataModel.h"

@implementation BCWalletExchangeDataModel

- (void)setExchangeData:(UserWalletExchangeData *)exchangeData {
    _exchangeData = exchangeData;
    //
    NSArray *data = exchangeData.data;
    if (!self.fromCurrency) {//如果没有赋予第一个
        if (data.count) {
            self.fromCurrency = exchangeData.data[0];
        }
    }else {//如果有要用替换掉
        for (UserWalletExchangeDataCurrencyModel *model in data) {
            if ([model.cur_id isEqualToString:self.fromCurrency.cur_id]) {
                self.fromCurrency = model;
                break;
            }
        }
    }
    //
    if (!self.toCurrency) {//如果没有赋予第二个
        if (data.count>1) {
            self.toCurrency = exchangeData.data[1];
        }
    }else {
        for (UserWalletExchangeDataCurrencyModel *model in data) {
            if ([model.cur_id isEqualToString:self.toCurrency.cur_id]) {
                self.toCurrency = model;
                break;
            }
        }
    }
}

@end
